Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
vscode-json-languageservice
Advanced tools
The vscode-json-languageservice npm package provides a set of services for working with JSON documents in a way that is compatible with the Visual Studio Code editor. It offers features such as validation, completion, hover information, and more, making it easier to build tools and extensions that work with JSON data.
Validation
This feature allows you to validate JSON documents. The code sample demonstrates how to use the language service to validate a JSON document and print out any diagnostics (errors or warnings) found.
const { getLanguageService } = require('vscode-json-languageservice');
const languageService = getLanguageService({});
const document = { uri: 'file://test.json', languageId: 'json', version: 1, getText: () => '{ "key": "value" }' };
const jsonDocument = languageService.parseJSONDocument(document);
languageService.doValidation(document, jsonDocument).then(diagnostics => {
console.log(diagnostics);
});
Completion
This feature provides auto-completion suggestions for JSON documents. The code sample shows how to get completion suggestions at a specific position in a JSON document.
const { getLanguageService } = require('vscode-json-languageservice');
const languageService = getLanguageService({});
const document = { uri: 'file://test.json', languageId: 'json', version: 1, getText: () => '{ "key": "value" }' };
const jsonDocument = languageService.parseJSONDocument(document);
languageService.doComplete(document, { line: 0, character: 1 }, jsonDocument).then(completionList => {
console.log(completionList);
});
Hover Information
This feature provides hover information for JSON documents. The code sample demonstrates how to get hover information at a specific position in a JSON document.
const { getLanguageService } = require('vscode-json-languageservice');
const languageService = getLanguageService({});
const document = { uri: 'file://test.json', languageId: 'json', version: 1, getText: () => '{ "key": "value" }' };
const jsonDocument = languageService.parseJSONDocument(document);
languageService.doHover(document, { line: 0, character: 1 }, jsonDocument).then(hover => {
console.log(hover);
});
jsonlint is a JSON parser and validator with a CLI. It is primarily used for validating JSON data and providing error messages. Unlike vscode-json-languageservice, it does not offer features like completion or hover information.
ajv is a JSON schema validator that supports JSON Schema draft-07 and other standards. It is highly performant and can be used for validating JSON data against schemas. While it focuses on validation, it does not provide language service features like completion or hover information.
json-schema-to-typescript converts JSON schemas to TypeScript interfaces. It is useful for generating TypeScript types from JSON schemas but does not offer the comprehensive language services provided by vscode-json-languageservice.
JSON language service extracted from VSCode to be reused, e.g in the Monaco editor.
The vscode-json-languageservice contains the language smarts behind the JSON editing experience of Visual Studio Code and the Monaco editor.
npm install --save vscode-json-languageservice
FAQs
Language service for JSON
The npm package vscode-json-languageservice receives a total of 1,044,132 weekly downloads. As such, vscode-json-languageservice popularity was classified as popular.
We found that vscode-json-languageservice demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.